package a66weding.com.jiehuntong.activity.toolsinvitation;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.TextView;

import a66weding.com.jiehuntong.R;
import me.imid.swipebacklayout.lib.app.SwipeBackActivity;

public class ToolsInvitationDetailActivity extends SwipeBackActivity implements View.OnClickListener {
    private TextView mTitleTv;
    private TextView mBackTv;
    private TextView mHeadRightfuncTv;
    private LinearLayout mBackLay;
    private LinearLayout mSelectPlaceLay;


    private WebView mWebView;
    private WebSettings webSettings;
    private String url;
    private String backTv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tools_invitationdetail);

        Intent intent = getIntent();
        if(intent!=null){
            url = intent.getStringExtra("url");
        }

        initview();

        initdata();
    }



    private void initview() {
        mTitleTv = (TextView) findViewById(R.id.tv_header_title);
        mBackTv = (TextView) findViewById(R.id.tv_header_backcontent);
        mBackLay = (LinearLayout) findViewById(R.id.llay_header_back);
        mSelectPlaceLay = (LinearLayout) findViewById(R.id.lay_header_place);
        mHeadRightfuncTv = (TextView) findViewById(R.id.tv_header_function);
        mWebView = (WebView) findViewById(R.id.webview_tools);

        mTitleTv.setText("预览");
        mBackTv.setText("返回");

        mHeadRightfuncTv.setVisibility(View.GONE);

        mBackLay.setOnClickListener(this);

    }


    private void initdata() {

        webSettings = mWebView.getSettings();
        setWebview(webSettings);
        mWebView.loadUrl(url);

    }


    private void setWebview(WebSettings settings) {
        //设置支持JavaScript:一般必须设置
        settings.setJavaScriptEnabled( true);
        //设置支持双击变大变小
        settings.setUseWideViewPort( true);
        //设置支持按钮点击
        settings.setBuiltInZoomControls( true);
        //支持从html中弹出对话框
        mWebView.setWebChromeClient(new WebChromeClient());
        //设置以什么编码方式打开
        settings.setDefaultTextEncodingName("utf-8");

    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
                case R.id.llay_header_back:
                    finish();
                break;
        }
    }



}
